import {HTTP} from "../utils/http-p";
class Keyword extends HTTP{
    // 得到历史记录
    getHistory() {
        const words = wx.getStorageSync('q');
        if (words) {
            return words
        } else {
            return [];
        }
    }
    // 添加到历史记录
    addHistory(value) {
        var words = this.getHistory();
        const has = words.includes(value);
        if (value && !has) {
            if (words.length > 3) {
                words.pop();
            }
            words.unshift(value);
            wx.setStorageSync('q', words);
        }
    }
    // 获取热搜关键字
    getHotData(){
        return this.request({
            url:`/book/hot_keyword`
        })
    } 
    // 书籍搜索
    getKeyword(start,value){
        return this.request({
            url:`/book/search`,
            data:{
                start,
                q:value
            }
        })
    }
}
export {
    Keyword
}